package licode.unisop.provider.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 属性项信息
 *
 * @author licode
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SiPropItem {
    private String name;
    private Object value;

    public String getString(String defVal) {
        if (value instanceof String) {
            return (String) value;
        } else {
            return defVal;
        }
    }

    public Long getLong(Long defVal) {
        if (value instanceof Long) {
            return (Long) value;
        } else if (value instanceof Integer) {
            return ((Integer) value).longValue();
        } else if (value instanceof Short) {
            return ((Short) value).longValue();
        } else {
            return defVal;
        }
    }

    public Double getDouble(Double defVal) {
        if (value instanceof Double) {
            return (Double) value;
        } else if (value instanceof Float) {
            return ((Float) value).doubleValue();
        } else {
            return defVal;
        }
    }
}
